package com.naizhuai.ui.mianbusiness.presenter;

import com.naizhuai.AppContext;
import com.naizhuai.network.Config;
import com.naizhuai.network.RetrofitServerFactory;
import com.naizhuai.network.apistore.PublicDataRequest;
import com.naizhuai.ui.entity.LabelsConvertBean;
import com.naizhuai.ui.entity.VirtualChosenBean;
import com.naizhuai.util.RxUtils;


import java.util.List;

import rx.Observable;

/**
 * 处理公共搜索的类
 * Created by code_han on 2018/1/25.
 */

public class PublicDataApiStoreIml implements PublicDataApiStore {

    private static PublicDataApiStore INSTANCE = null;

    public static PublicDataApiStore getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new PublicDataApiStoreIml();
        }
        return INSTANCE;
    }

    @Override
    public Observable<List<LabelsConvertBean>> getConvertDatas(String companyId) {
        return createBaseClass().getConvertDatas(companyId).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<List<VirtualChosenBean>> getChosenManage(int serverType,String serverId,String query) {
        return createBaseClass().getChosenManage(serverType,serverId,query).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<List<VirtualChosenBean>> getChosenPeople(int serverType,String serverId,String query) {
        return createBaseClass().getChosenPeople(serverType,serverId,query).compose(RxUtils.applySchedulers());
    }
    @Override
    public Observable<List<VirtualChosenBean>> getChosenGroup(int serverType,String serverId) {
        return createBaseClass().getChosenGroup(serverType,serverId).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<List<VirtualChosenBean>> getAddPeople(String query) {
        return createBaseClass().getAddPeople(query).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<List<VirtualChosenBean>> getThankPeople(String query) {
        return createBaseClass().getThankPeople(query).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<String> postThumbUps(String thumbsType,String schemeId) {
        return createBaseClass().postThumbUps(thumbsType,schemeId).compose(RxUtils.applySchedulers());
    }
    @Override
    public Observable<String> postSuggestion(String content) {
        return createBaseClass().postSuggestion(content).compose(RxUtils.applySchedulers());
    }

    private PublicDataRequest createBaseClass() {
        return RetrofitServerFactory.create(AppContext.getInstance(), PublicDataRequest.class, Config.COMPANY_COMMON_BASE_URL);
    }


}
